Skip to content

test(frontend): add unit tests for FileSaverService#6460

Open
Ma77Ball wants to merge 8 commits into
apache:mainfrom
Ma77Ball:test/file-saver-service-spec
Open

test(frontend): add unit tests for FileSaverService#6460
Ma77Ball wants to merge 8 commits into
apache:mainfrom
Ma77Ball:test/file-saver-service-spec

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Adds file-saver.service.spec.ts covering FileSaverService; no production code changed.
  • Verifies delegation to FileSaver.saveAs for Blob and string payloads.
  • Covers the case where filename and options are omitted (undefined is passed through).

Any related issues, documentation, discussions?

Closes: #6448

How was this PR tested?

  • Run cd frontend && npx nx test gui --include="**/file-saver.service.spec.ts", expect 4 passed.
  • Full frontend suite runs in CI via yarn test:ci, selected by the auto-applied frontend label.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

❌ 5 Tests Failed:

Tests completed Failed Passed Skipped
3709 5 3704 2
View the top 3 failed test(s) by shortest run time
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > propagates errors thrown by saveAs instead of swallowing them
Stack Traces | 0.00568s run time
AssertionError: expected function to throw an error, but it didn't
 ❯ .../user/file/file-saver.service.spec.ts:80:66
 ❯ src/test-zone-setup.ts:90:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ZoneImpl.run node_modules/zone.js/fesm2015/zone.js:113:43
 ❯ src/test-zone-setup.ts:88:16
 ❯ new ZoneAwarePromise node_modules/zone.js/fesm2015/zone.js:2701:25
 ❯ wrapper src/test-zone-setup.ts:86:16
 ❯ src/test-zone-setup.ts:90:33
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > propagates errors thrown by saveAs
Stack Traces | 0.00636s run time
AssertionError: expected function to throw an error, but it didn't
 ❯ .../user/file/file-saver.service.spec.ts:63:57
 ❯ src/test-zone-setup.ts:90:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ZoneImpl.run node_modules/zone.js/fesm2015/zone.js:113:43
 ❯ src/test-zone-setup.ts:88:16
 ❯ new ZoneAwarePromise node_modules/zone.js/fesm2015/zone.js:2701:25
 ❯ wrapper src/test-zone-setup.ts:86:16
 ❯ src/test-zone-setup.ts:90:33
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > passes undefined through when filename and options are omitted
Stack Traces | 0.00656s run time
AssertionError: expected "vi.fn()" to be called with arguments: [ Blob{ …(1) }, undefined, undefined ]

Number of calls: 0

 ❯ .../user/file/file-saver.service.spec.ts:71:20
 ❯ src/test-zone-setup.ts:90:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ZoneImpl.run node_modules/zone.js/fesm2015/zone.js:113:43
 ❯ src/test-zone-setup.ts:88:16
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > delegates a Blob payload to saveAs with filename and options
Stack Traces | 0.00816s run time
AssertionError: expected "vi.fn()" to be called 1 times, but got 0 times
 ❯ .../user/file/file-saver.service.spec.ts:47:20
 ❯ src/test-zone-setup.ts:90:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ZoneImpl.run node_modules/zone.js/fesm2015/zone.js:113:43
 ❯ src/test-zone-setup.ts:88:16
 ❯ new ZoneAwarePromise node_modules/zone.js/fesm2015/zone.js:2701:25
 ❯ wrapper src/test-zone-setup.ts:86:16
 ❯ src/test-zone-setup.ts:90:33
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > forwards a string payload (e.g. a URL) unchanged
Stack Traces | 0.658s run time
AssertionError: expected "vi.fn()" to be called with arguments: [ Array(3) ]

Number of calls: 0

 ❯ .../user/file/file-saver.service.spec.ts:54:20
 ❯ src/test-zone-setup.ts:90:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ZoneImpl.run node_modules/zone.js/fesm2015/zone.js:113:43
 ❯ src/test-zone-setup.ts:88:16

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Vitest unit coverage for the frontend FileSaverService (a thin wrapper around file-saver), improving confidence that the service correctly delegates payloads and optional arguments.

Changes:

  • Adds file-saver.service.spec.ts to verify delegation to file-saver’s saveAs for Blob and string inputs.
  • Adds assertions for pass-through behavior when filename and options are omitted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xinyuan Lin <xinyual3@uci.edu>
@aglinxinyuan
aglinxinyuan enabled auto-merge July 22, 2026 01:25
Ma77Ball and others added 3 commits July 21, 2026 19:39
auto-merge was automatically disabled July 22, 2026 03:04

Head branch was pushed to by a user without write access

@aglinxinyuan

Copy link
Copy Markdown
Contributor

please fix the ci

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add frontend unit tests for FileSaverService

4 participants